package com.msw.sentinel.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.stereotype.Service;

/**
 * @author mashuangwei
 * @version 1.0.0
 * @date 2019-09-01 18:33:40
 */
@Service
public class DemoService {

    @SentinelResource(value = "sayhi", fallback = "fallBack")
    public String sayHi(String content){
        return "hi " + content;
    }

    public void fallBack(String content){
        System.err.println("fallBack receive " + content);
    }

    @SentinelResource(value = "test", blockHandler = "exceptionHandler")
    public String HelloWorld(String content) {
        System.out.println("调用get()");
        return "hello" + content;
    }

    public void exceptionHandler(BlockException e) {
        e.printStackTrace();
        System.out.println("出错！！！");
    }

}
